from dataclasses import dataclass
import datetime

@dataclass
class LodgerItem:
	id: int = 0
	fio: str = ''
	room: str = ''
	count: str = ''
	child: str = ''
	time = 0

	def __post_init__(self):
		self.time = datetime.datetime.now()

	def setData(self, d):
		if d:
			self.__dict__.update(d)

	def getData(self):
		return self.__dict__

	def getInfo(self):
		return [self.id, self.fio]

	def input(self, io):
		self.id = int(io.inputField('id', 'ID', self.id))
		self.fio = io.inputField('fio', 'Fio')
		self.room = io.inputField('room', 'Room')
		self.count = io.inputField('count', 'Count')
		self.child = io.inputField('child', 'Child')
	
	def output(self, io):
		return io.outputItem(self)

	def edit(self, io):
		return io.editItem(self)

	def __str__(self):
		return f"""
ID: {self.id}	
Fio: {self.fio}	
Room: {self.room}	
Count: {self.count}	
Child: {self.child}
Time: {self.time}
--	
	"""
